<template>
    <div>
        <VoSchemaForm :model="model" :schema="schema"></VoSchemaForm>
        <div>
            <pre>{{modelJson}}</pre>
        </div>
        <div class="markdown-body">
            <CodeTpl></CodeTpl>
        </div>
    </div>
</template>

<script>
import CodeTpl from '@/views/md/sf/transfer.md';
export default {
    components: {
        CodeTpl
    },
    data() {
        return {
            model: {},
            schema: {
                properties: {
                    name1: {
                        label: '属性',
                        widget: 'transfer',
                        enum: [
                            { label: '选项1', key: '1' },
                            { label: '选项2', key: '2' },
                            { label: '选项3', key: '3' },
                            { label: '选项4', key: '4' }
                        ],
                        ui: {
                            filterable: true,
                            filterPlaceholder: '检索'
                        }
                    },
                    name2: {
                        label: '异步选项',
                        widget: 'transfer',
                        enum: [],
                        asyncData(resolve) {
                            setTimeout(() => {
                                resolve([
                                    { label: '选项1', key: '1' },
                                    { label: '选项2', key: '2' },
                                    { label: '选项3', key: '3' },
                                    { label: '选项4', key: '4' }
                                ])
                            }, 2000)
                        }
                    },
                    name3: {
                        label: '插槽',
                        widget: 'transfer',
                        enum: [
                            { label: '选项1', key: '1' },
                            { label: '选项2', key: '2' },
                            { label: '选项3', key: '3' },
                            { label: '选项4', key: '4' }
                        ],
                        slots: {
                            default(h, { option }) {
                                return option.label + 'o(*￣︶￣*)o'
                            },
                            leftFooter(h) {
                                return <el-button>左侧</el-button>
                            },
                            rightFooter(h) {
                                return <el-button>右侧</el-button>
                            }
                        }
                    }
                },
                ui: {
                    labelWidth: 100
                },
                col: {
                    span: 24
                }
            }
        }
    },
    computed: {
        modelJson() {
            return JSON.stringify(this.model, null, 4)
        }
    }
}
</script>

<style>

</style>
